package bing.netty.example.timewithpojo;

import java.util.Date;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;

public class TimeClientHandler extends ChannelHandlerAdapter{

	@Override
	public void channelRead(ChannelHandlerContext ctx,Object msg){
		/*
		ByteBuf ms=(ByteBuf)msg;
		try{
		  long currentTimeMills=(ms.readUnsignedInt()-2208988800L)* 1000L;
		  System.out.println(new Date(currentTimeMills));
		}finally{
			ms.release();
		}*/
		
		UnixTime m=(UnixTime)msg;
		System.out.println(m);
		ctx.close();
	}
	
	@Override
	public void exceptionCaught(ChannelHandlerContext ctx,Throwable cause){
		cause.printStackTrace();
		ctx.close();
		
	}
}
